/* ICQProtocolFeatures.java
 *
 * Copyright 2011 Aleksey Konovalov
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 * 
 */

package org.jimm.im.icq;

import java.util.HashMap;

import android.util.Log;
import org.jimm.protocols.icq.setting.enumerations.XStatusModeEnum;
import org.jimm.app.R;
import org.jimm.im.Contact;
import org.jimm.im.ProtocolFeatures;

public final class ICQProtocolFeatures implements ProtocolFeatures {

	private static final String LOG_TAG = "Jimm:ICQProtocolFeatures";

	private static final HashMap<Integer, Integer> statusIcons = new HashMap<Integer, Integer>();
	private static final HashMap<Integer, Integer> additionalStatusIcons = new HashMap<Integer, Integer>();

	static {
		statusIcons.put(Contact.MAIN_STATUS_OFFLINE, R.drawable.icq_status_offline);
		statusIcons.put(Contact.MAIN_STATUS_ONLINE, R.drawable.icq_status_online);
		statusIcons.put(Contact.MAIN_STATUS_AWAY, R.drawable.icq_status_away);
		statusIcons.put(Contact.MAIN_STATUS_DND, R.drawable.icq_status_dnd);
		statusIcons.put(Contact.MAIN_STATUS_NA, R.drawable.icq_status_na);
		statusIcons.put(Contact.MAIN_STATUS_OCCUPIED, R.drawable.icq_status_occupied);
		statusIcons.put(Contact.MAIN_STATUS_FREE_FOR_CHAT, R.drawable.icq_status_ffc);
		statusIcons.put(Contact.MAIN_STATUS_INVISIBLE, R.drawable.icq_status_invisible);
		statusIcons.put(Contact.MAIN_STATUS_LUNCH, R.drawable.icq_status_lunch);
		statusIcons.put(Contact.MAIN_STATUS_EVIL, R.drawable.icq_status_evil);
		statusIcons.put(Contact.MAIN_STATUS_DEPRESSION, R.drawable.icq_status_depression);
		statusIcons.put(Contact.MAIN_STATUS_HOME, R.drawable.icq_status_home);
		statusIcons.put(Contact.MAIN_STATUS_WORK, R.drawable.icq_status_work);
		
		additionalStatusIcons.put(XStatusModeEnum.ANGRY, R.drawable.ic_icq_additional_status_angry);
		additionalStatusIcons.put(XStatusModeEnum.TAKING_A_BATH, R.drawable.ic_icq_additional_status_bath);
		additionalStatusIcons.put(XStatusModeEnum.TIRED, R.drawable.ic_icq_additional_status_tired);
		additionalStatusIcons.put(XStatusModeEnum.PARTY, R.drawable.ic_icq_additional_status_party);
		additionalStatusIcons.put(XStatusModeEnum.DRINKING_BEER, R.drawable.ic_icq_additional_status_drinking);
		additionalStatusIcons.put(XStatusModeEnum.THINKING, R.drawable.ic_icq_additional_status_thinking);
		additionalStatusIcons.put(XStatusModeEnum.EATING, R.drawable.ic_icq_additional_status_eating);
		additionalStatusIcons.put(XStatusModeEnum.WATCHING_TV, R.drawable.ic_icq_additional_status_tv);
		additionalStatusIcons.put(XStatusModeEnum.MEETING, R.drawable.ic_icq_additional_status_meeting);
		additionalStatusIcons.put(XStatusModeEnum.COFFEE, R.drawable.ic_icq_additional_status_coffee);
		additionalStatusIcons.put(XStatusModeEnum.LISTENING_TO_MUSIC, R.drawable.ic_icq_additional_status_music);
		additionalStatusIcons.put(XStatusModeEnum.BUSINESS, R.drawable.ic_icq_additional_status_business);
		additionalStatusIcons.put(XStatusModeEnum.FILM, R.drawable.ic_icq_additional_status_film);
		additionalStatusIcons.put(XStatusModeEnum.HAVING_FUN, R.drawable.ic_icq_additional_status_fun);
		additionalStatusIcons.put(XStatusModeEnum.ON_THE_PHONE, R.drawable.ic_icq_additional_status_phone);
		additionalStatusIcons.put(XStatusModeEnum.GAMING, R.drawable.ic_icq_additional_status_gaming);
		additionalStatusIcons.put(XStatusModeEnum.STUDYING, R.drawable.ic_icq_additional_status_studying);
		additionalStatusIcons.put(XStatusModeEnum.SHOPPING, R.drawable.ic_icq_additional_status_shopping);
		additionalStatusIcons.put(XStatusModeEnum.FEELING_SICK, R.drawable.ic_icq_additional_status_illness);
		additionalStatusIcons.put(XStatusModeEnum.SLEEPING, R.drawable.ic_icq_additional_status_sleeping);
		additionalStatusIcons.put(XStatusModeEnum.SURFING, R.drawable.ic_icq_additional_status_surfing);
		additionalStatusIcons.put(XStatusModeEnum.BROWSING, R.drawable.ic_icq_additional_status_browsing);
		additionalStatusIcons.put(XStatusModeEnum.WORKING, R.drawable.ic_icq_additional_status_working);
		additionalStatusIcons.put(XStatusModeEnum.TYPING, R.drawable.ic_icq_additional_status_typing);
		additionalStatusIcons.put(XStatusModeEnum.PICNIC, R.drawable.ic_icq_additional_status_picnic);
		additionalStatusIcons.put(XStatusModeEnum.PDA, R.drawable.ic_icq_additional_status_pda);
		additionalStatusIcons.put(XStatusModeEnum.MOBILE, R.drawable.ic_icq_additional_status_mobile);
		additionalStatusIcons.put(XStatusModeEnum.ZZZ, R.drawable.ic_icq_additional_status_zzz);
		additionalStatusIcons.put(XStatusModeEnum.ON_WC, R.drawable.ic_icq_additional_status_toilet);
		additionalStatusIcons.put(XStatusModeEnum.QUESTION, R.drawable.ic_icq_additional_status_question);
		additionalStatusIcons.put(XStatusModeEnum.WATCHING_PRO7, R.drawable.ic_icq_additional_status_pro7);
		additionalStatusIcons.put(XStatusModeEnum.LOVE, R.drawable.ic_icq_additional_status_heart);
		additionalStatusIcons.put(XStatusModeEnum.GOOGLE, R.drawable.ic_icq_additional_status_google);
		additionalStatusIcons.put(XStatusModeEnum.NOTEPAD, R.drawable.ic_icq_additional_status_notepad);
		additionalStatusIcons.put(XStatusModeEnum.SEX, R.drawable.ic_icq_additional_status_sex);
	}

	@Override
	public String getName() {
		return "ICQ";
	}

	@Override
	public int getMainStatusPictureId(int status) {
		Integer id = statusIcons.get(status);
		if(id != null)
			return id;

		Log.w(LOG_TAG, "Unknown main status " + status);
		return R.drawable.icq_status_offline;
	}

	@Override
	public int getAdditionalStatusPictureId(int additionalStatus) {
		Integer status = additionalStatusIcons.get(additionalStatus);
		if (status == null && additionalStatus != 0)
			Log.w(LOG_TAG, "Unknown additional status " + additionalStatus);
		return status != null ? status : 0;
	}
	
}
